﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:tx="http://www.springframework.net/tx"
         xmlns:db="http://www.springframework.net/database"
         xmlns:aop="http://www.springframework.net/aop">

	<!-- Referenced by main application context configuration file -->
	<description>
		The project definitions for the Data Access Objects.
	</description>

	<!-- Property placeholder configurer for database settings 用以我们在其它的应用程序中，配置数据访问 -->
	<object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
		<property name="ConfigSections" value="databaseSettings"/>
	</object>

	<!-- Database Configuration 数据库和Nhibernate的相关配置 -->
	<db:provider id="DbProvider"
					 provider="SqlServer-2.0"
					 connectionString="Server=(local);initial catalog=CanyinSystem;Integrated Security=SSPI"/>

	<!-- NHibernate Configuration SessionFactory对象，其中包括一些比较重要的属性 -->
	<object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate33">
		<property name="DbProvider" ref="DbProvider"/>
		<property name="MappingAssemblies">
			<list>
				<value>YiLe.Model</value>
			</list>
		</property>
		<property name="HibernateProperties">
			<dictionary>
				<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
				<entry key="dialect" value="NHibernate.Dialect.MsSql2008Dialect"/>
				<entry key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
				<!--<entry key="use_proxy_validator" value="false" />-->				
			</dictionary>
		</property>
		<!-- provides integation with Spring's declarative transaction management features -->
		<property name="ExposeTransactionAwareSessionFactory" value="true" />
	</object>

	<!-- Exception translation object post processor 异常处理 -->
	<object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>
	
	<!-- Transaction Management Strategy - local database transactions  此处取消事务
	<object id="transactionManager"
		  type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate33">
		<property name="DbProvider" ref="DbProvider"/>
		<property name="SessionFactory" ref="NHibernateSessionFactory"/>
	</object>-->
	<!--此处取消事务
	<tx:attribute-driven transaction-manager="transactionManager"/>
	-->
	
	<!-- Data Access Objects 
	<object id="GI_UserDAO" type="GoodsInvoicing.DAL.Hibernate.UserRole.GI_UserDAOHibernate, GoodsInvoicing">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>-->
	
	<!--引入HibernateTemplate模板 -->
	<object id="HibernateTemplate" type="Spring.Data.NHibernate.Generic.HibernateTemplate">
		<property name="SessionFactory" ref="NHibernateSessionFactory" />
		<property name="TemplateFlushMode" value="Auto" />
		<property name="CacheQueries" value="true" />
	</object>
	<!--以下为注入Data Access Objects -->
	<object id="XS_CodeDao" type="YiLe.DAL.NHibernate.XS_CodeDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="Xs_TableDao" type="YiLe.DAL.NHibernate.Xs_TableDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="Xs_FoodDao" type="YiLe.DAL.NHibernate.Xs_FoodDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="UserDao" type="YiLe.DAL.NHibernate.UserDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="RoleDao" type="YiLe.DAL.NHibernate.RoleDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="PermissionDao" type="YiLe.DAL.NHibernate.PermissionDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>

	<object id="MenuDao" type="YiLe.DAL.NHibernate.MenuDaoHibernate, YiLe.DAL">
		<property name="HibernateTemplate" ref="HibernateTemplate"/>
	</object>
</objects>
